package com.qf.test.pojo;

import java.util.HashMap;
//封装一个返回的结果实体类
public class Result extends HashMap {
    //响应消息
    private String  msg;

    //响应状态码  0成功  1失败
    private int code;
    //无参构造
    public Result(){}
    //有参构造
    public Result( int code,String msg){
        this.code=code;
        this.msg=msg;
    }
    //有参构造
    public  Result(int code){
        this.code=code;
    }
    //有参构造
    public Result(String msg){
        this.msg=msg;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
    //返回成功消息的状态码
    public static Result ok(){
        return new Result(0);
    }
    //返回成功的消息
    public static Result ok(String msg){
        return new Result(0,msg);
    }
    public static Result error(){
        return new Result(1);

    }
    public static Result error(String msg){
        return new Result(1,msg);
    }
    public Result put(String key,Object value){
        super.put(key,value);
        return this;
    }


}
